package com.dxq.test.adapter;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ColorUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dxq.test.R;
import com.dxq.test.db.Pasture;

import java.util.List;

/**
 * Author: zsh
 * Date: 2023/12/01
 * Describe: 牧场列表adapter
 */
public class PastureAdapter extends BaseQuickAdapter<Pasture, BaseViewHolder> {

    public PastureAdapter(int layoutResId) {
        this(layoutResId, null);
    }

    public PastureAdapter(int layoutResId, @Nullable List<Pasture> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, Pasture item) {
        //holder.setText(R.id.tvSize, String.valueOf(1 + holder.getLayoutPosition()));
        if (item.isCheck()) {
            holder.setBackgroundColor(R.id.llMain, ColorUtils.getColor(R.color.colorCC));
            holder.setTextColor(R.id.tvName, ColorUtils.getColor(R.color.colorRed));
        } else {
            holder.setBackgroundColor(R.id.llMain, ColorUtils.getColor(R.color.colorF1));
            holder.setTextColor(R.id.tvName, ColorUtils.getColor(R.color.black));
        }
        holder.setText(R.id.tvName, item.getName());
        holder.setImageResource(R.id.ivCheck, R.drawable.baseline_check_circle_24);
        holder.setGone(R.id.ivCheck, !item.isCheck());
    }
}
